Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
How to remove the "T" value in datetime-local input type?

I am using datetime-local input type in HTML, but I don't want to use the "T" on the output. I want to only get the date and time with a space between.

<input type="datetime-local" id="date" name="date">

The output is:

2021-11-08T16:34

What i want is:

2021-11-08 16:34

What do i need to do to get this output?

PS: Try to help me without bootstrap libraries, because on this project i can't use it.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As Dima Parzhitsky wrote, consider to use Intl.DateTimeFormat methods

const
  localDt =_=>
    {
    let now = new Date()
    now.setMinutes(now.getMinutes() - now.getTimezoneOffset())
    now.setSeconds(0)       // remove seconds
    now.setMilliseconds(0) // remove milliseconds
    return now
    }
, fxDate = 
    Intl.DateTimeFormat( undefined,
    { hour12: false, year: 'numeric', month: '2-digit'
    , day: '2-digit', hour: '2-digit', minute: '2-digit'
    })
, dtForm = d => 
    {
    let {day,month,year,hour,minute} = 
      fxDate.formatToParts(d).reduce((o,{type,value})=>(o[type]=value,o),{})
    return `${year}-${month}-${day} ${hour}:${minute}`
    }


dateInput.valueAsDate = localDt()  // init date value 

getDate.onclick =_=>
  {
  let dt = dateInput.valueAsDate
  dt.setMinutes(dt.getMinutes() + dt.getTimezoneOffset())

  dateStr.textContent = dtForm(dt) 
  }
<input type="datetime-local" id="dateInput">
<br><br>
<button id="getDate">get Date</button>


<p id="dateStr">???</p>

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can try this, I use pure javascript

//get the date
  var x = document.getElementById("date").value;

//this replaces the 'T' with an space
  x = x.replace("T", " ");

//this places the string back on the HTML page
  document.getElementById("demo").innerHTML = x;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda